#include "painterarea.h"

painterarea::painterarea(QWidget *parent) : QWidget(parent)
{
    setMinimumSize(410,410);

    QPalette palette(this->palette());
    palette.setColor(QPalette::Background, Qt::red);
    this->setPalette(palette);
    setAutoFillBackground(true);


}

void painterarea::myShape(painterarea::shape sh)
{
    shp=sh;
    update();
}

void painterarea::myPen(QPen ph)
{
    pen=ph;
    update();
}

void painterarea::myBrush(QBrush bruh)
{
    brush=bruh;
    update();
}

void painterarea::myfillRule(Qt::FillRule fill)
{
    fill1=fill;
    update();
}

void painterarea::paintEvent(QPaintEvent *event)
{
   painter=new QPainter(this);
   painter->setBrush(brush);
   painter->setPen(pen);

   QRect rect(55,110,290,180);
   switch(shp)
   {
   case Line:
       painter->drawLine(rect.topLeft(),rect.bottomRight());
       break;
   case Rectangle:
       painter->drawRect(rect);
       break;
   default:
       break;

   }

}
